package com.cxy.rpc;

import com.cxy.rpc.rpc.RpcClientFrame;
import com.cxy.rpc.vo.UserInfo;
import com.cxy.service.SendSms;
import com.cxy.service.StockService;

/**
 * 
 *类说明：rpc的客户端，调用远端服务
 */
public class RpcClient {
    public static void main(String[] args) {
    	//以下没注释部分为RPC调用服务
        UserInfo userInfo
                = new UserInfo("Mark","Mark@xiangxue.com");

        SendSms sendSms = RpcClientFrame.getRemoteProxyObj(SendSms.class,
                "127.0.0.1",9189);
        System.out.println("Send mail: "+ sendSms.sendMail(userInfo));

        StockService stockService
                = RpcClientFrame.getRemoteProxyObj(StockService.class,
                "127.0.0.1",9190);
        stockService.addStock("A001",1000);
        stockService.deduceStock("B002",50);

        //注释部分為单应用调用方法
//        StockService stockService = new StockServiceImpl();
//        stockService.addStock("A001",1000);
//        stockService.deduceStock("B002",50);

    }
}
